package com.ruoyi.zxjd.work.service.impl;

import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.common.utils.ShiroUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.zxjd.work.mapper.WorkTemplateTable3Mapper;
import com.ruoyi.zxjd.work.domain.WorkProgress;
import com.ruoyi.zxjd.work.domain.WorkTemplateTable3;
import com.ruoyi.zxjd.work.domain.bo.WorkProgressBO;
import com.ruoyi.zxjd.work.service.IWorkTemplateTable3Service;
import com.ruoyi.common.core.text.Convert;

/**
 * 党风廉政建设外宣稿件情况统计Service业务层处理
 * 
 * @author lcc
 * @date 2021-02-25
 */
@Service
public class WorkTemplateTable3ServiceImpl implements IWorkTemplateTable3Service 
{
    @Autowired
    private WorkTemplateTable3Mapper workTemplateTable3Mapper;
    @Autowired
    private WorkProgressServiceImpl workProgressService;

    /**
     * 查询党风廉政建设外宣稿件情况统计
     * 
     * @param id 党风廉政建设外宣稿件情况统计ID
     * @return 党风廉政建设外宣稿件情况统计
     */
    @Override
    public WorkTemplateTable3 selectWorkTemplateTable3ById(Long id)
    {
        return workTemplateTable3Mapper.selectWorkTemplateTable3ById(id);
    }

    /**
     * 查询党风廉政建设外宣稿件情况统计列表
     * 
     * @param workTemplateTable3 党风廉政建设外宣稿件情况统计
     * @return 党风廉政建设外宣稿件情况统计
     */
    @Override
    public List<WorkTemplateTable3> selectWorkTemplateTable3List(WorkTemplateTable3 workTemplateTable3)
    {
        return workTemplateTable3Mapper.selectWorkTemplateTable3List(workTemplateTable3);
    }

    /**
     * 新增党风廉政建设外宣稿件情况统计
     * 
     * @param workTemplateTable3 党风廉政建设外宣稿件情况统计
     * @return 结果
     */
    @Override
    public int insertWorkTemplateTable3(WorkProgressBO workProgressBO)
    {
        WorkProgress workProgress = workProgressBO.getWorkProgress();
        List<WorkTemplateTable3> WorkTemplateTable3List = workProgressBO.getWorkTemplateTable3List();
        for (WorkTemplateTable3 Table : WorkTemplateTable3List) {
            Table.setCreateBy(ShiroUtils.getLoginName());
            Table.setCreateTime(DateUtils.getNowDate());
            Table.setProgressId(workProgress.getProgressId());
            workTemplateTable3Mapper.insertWorkTemplateTable3(Table);
        }
        return workProgressService.validate(workProgress);
    }

    /**
     * 修改党风廉政建设外宣稿件情况统计
     * 
     * @param workTemplateTable3 党风廉政建设外宣稿件情况统计
     * @return 结果
     */
    @Override
    public int updateWorkTemplateTable3(WorkTemplateTable3 workTemplateTable3)
    {
        workTemplateTable3.setUpdateBy(ShiroUtils.getLoginName());
        workTemplateTable3.setUpdateTime(DateUtils.getNowDate());
        return workTemplateTable3Mapper.updateWorkTemplateTable3(workTemplateTable3);
    }

    /**
     * 删除党风廉政建设外宣稿件情况统计对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteWorkTemplateTable3ByIds(String ids)
    {
        return workTemplateTable3Mapper.deleteWorkTemplateTable3ByIds(Convert.toStrArray(ids));
    }

    /**
     * 删除党风廉政建设外宣稿件情况统计信息
     * 
     * @param id 党风廉政建设外宣稿件情况统计ID
     * @return 结果
     */
    @Override
    public int deleteWorkTemplateTable3ById(Long id)
    {
        return workTemplateTable3Mapper.deleteWorkTemplateTable3ById(id);
    }

    /**
     * 查询党风廉政建设外宣稿件情况统计
     * 
     * @param progressId
     * @return 党风廉政建设外宣稿件情况统计
     */
    @Override
    public List<WorkTemplateTable3> selectWorkTemplateTable3ByProgressId(Long progressId)
    {
        return workTemplateTable3Mapper.selectWorkTemplateTable3ByProgressId(progressId);
    }

    /**
     * 查询党风廉政建设外宣稿件情况统计
     * 
     * @param arrangeId
     * @return 党风廉政建设外宣稿件情况统计
     */
    @Override
    public List<WorkTemplateTable3> selectWorkTemplateTable3ByArrangeId(Long arrangeId)
    {
        return workTemplateTable3Mapper.selectWorkTemplateTableByArrangeIdAndStatus(arrangeId);
    }
}
